package.path      = package.path .. ";.\\LuaSocket\\?.lua"
package.cpath     = package.cpath .. ";.\\LuaSocket\\?.dll"

SOCKET            = require("socket")
SOCKETURL         = require("url")
LTN12             = require("ltn12")
HTTP              = require("http")
SOCKET_HTTP = require("socket.http")

-- 发送请求的方法
function SendRequest(url, params)
    -- 构建请求头
    local headers = {
        ["Content-Type"] = "application/x-www-form-urlencoded",
        ["Content-Length"] = tostring(#params)
    }

    -- 发送POST请求
    local response = {}
    local result, status, headers = SOCKET.http.request {
        url = url,
        method = "POST",
        headers = headers,
        source = LTN12.source.string(params),
        sink = LTN12.sink.table(response)
    }

    -- 检查请求是否成功
    if status == 200 then
        local responseBody = table.concat(response)
        -- 处理返回的响应
        -- print("返回值: " .. responseBody)
        return responseBody
    else
        -- 请求失败，处理错误
        return "请求失败，状态码: " .. tostring(status)
    end
end
